<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\User;
use App\Models\Server;
use App\Helper;
use App\Models\Account;

class Pay extends Model
{
    protected $table ='paylogs';

    protected $filled = ['manager_id','server_id','player_id','order_num','type','money','payway','state','info','pay_purpose'];
    

    /**
     * [getManagerProfitList 获取用户收益列表]
     * @Author   WHJ
     * @DateTime 2019-10-27T17:39:50+0800
     * @return   [type]                   [description]
     */
    public function getManagerProfitList($manager_id)
    {
        $paylogs = $this->where('manager_id',$manager_id)->where('player_id','<>','0')->orderBy('created_at','desc')->paginate(10);
        return $paylogs;
    }

    /**
     * [getServerHost 获取对应服务器ip]
     * @Author   WHJ
     * @DateTime 2019-10-27T17:54:30+0800
     * @return   [type]                   [description]
     */
    public function getServerHost()
    {
    	return $this->belongsTo('App\Models\Server','server_id','id');
    }

    /**
     * [getPlayerInfo 获取玩家信息]
     * @Author   WHJ
     * @DateTime 2019-10-29T21:26:22+0800
     * @param    [type]                   $playerId [description]
     * @return   [type]                             [description]
     */
    public function getPlayerInfo($playerId)
    {
    	$server = Server::find($this->server_id);
        Helper::setDataBaseConf('mysql_auth',$server,'acore_auth');
        $player = Account::find($playerId);
        return $player;
    }
}
